#!/usr/bin/python
# -*- coding: utf-8 -*-

import unittest
from trivmoo.design_patterns.decorator.generic_decorator import GenericDecorator

class OOO(object):
    def method1(self):
        pass
    def method2(self):
        pass

class Myclass(OOO):
    def __init__(self):
        OOO.__init__(self)
    def method1(self):
        print "method1"
    def method2(self):
        print "method2"
        
class Mydecorator(GenericDecorator):
    def method3(self):
        print 'method3'
    def method4(self):
        print 'method4'

class Test(unittest.TestCase):
    def testMydecorator(self):
        """Test decorator"""
        
        #create the decorator
        o_decorator = Mydecorator(Myclass())
        
        # check the object implements all methods
        self.assertTrue(hasattr(o_decorator, "method1"))
        self.assertTrue(hasattr(o_decorator, "method2"))
        self.assertTrue(hasattr(o_decorator, "method3"))
        self.assertTrue(hasattr(o_decorator, "method4"))
        
        # the object is instance of Mydecorator, Myclass, 
        self.assertTrue(isinstance(o_decorator, Mydecorator))
        self.assertTrue(isinstance(o_decorator, GenericDecorator))
        


if __name__ == "__main__":
    unittest.main()